3 * Test class to run the query of most of all our special pages
5 * Copyright © 2011, Antoine Musso
7 * @author Antoine Musso
10 use MediaWiki\MediaWikiServices
;
14 * @covers QueryPage<extended>
16 class QueryAllSpecialPagesTest
extends MediaWikiTestCase
{
23 /** List query pages that can not be tested automatically */
24 protected $manualTest = [
29 * Pages whose query use the same DB table more than once.
30 * This is used to skip testing those pages when run against a MySQL backend
31 * which does not support reopening a temporary table. See upstream bug:
32 * https://bugs.mysql.com/bug.php?id=10327
34 protected $reopensTempTable = [
35 BrokenRedirects
::class,
39 * Initialize all query page objects
41 function __construct() {
42 parent
::__construct();
44 foreach ( QueryPage
::getPages() as $page ) {
47 if ( !in_array( $class, $this->manualTest
) ) {
48 $this->queryPages
[$class] =
49 MediaWikiServices
::getInstance()->getSpecialPageFactory()->getPage( $name );
55 * Test SQL for each of our QueryPages objects
58 public function testQuerypageSqlQuery() {
61 foreach ( $this->queryPages
as $page ) {
62 // With MySQL, skips special pages reopening a temporary table
63 // See https://bugs.mysql.com/bug.php?id=10327
66 && in_array( $page->getName(), $this->reopensTempTable
)
68 $this->markTestSkipped( "SQL query for page {$page->getName()} "
69 . "can not be tested on MySQL backend (it reopens a temporary table)" );
73 $msg = "SQL query for page {$page->getName()} should give a result wrapper object";
75 $result = $page->reallyDoQuery( 50 );
76 if ( $result instanceof ResultWrapper
) {
77 $this->assertTrue( true, $msg );
79 $this->assertFalse( false, $msg );